package com.api.sw.duban.web;

import com.alibaba.fastjson.JSONObject;
import com.api.sw.duban.action.DubanqsAction;
import com.api.sw.duban.action.DubanyBBAction;
import com.api.sw.duban.action.DubanyTzAction;
import com.api.sw.duban.util.CacheUtil;
import com.api.sw.duban.util.DubUtil;
import com.api.sw.duban.util.ExportWord;
import com.api.sw.duban.util.LogTool;
import com.engine.common.util.ParamUtil;
import com.weaver.formmodel.util.FileHelper;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.io.IOException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;

/*

    督办统计报表

 */
@Path("/dubanbb")
public class DbanTjTzAction {
    private final static LogTool log = new LogTool("/log/duban/",false);

    //获取查询列表数据页面
    @GET
    @Path("/tablelist")
    @Produces({"text/plain"})
    public String getQstablelist(@Context HttpServletRequest request, @Context HttpServletResponse response){
        Map<String, Object> apidatas = new HashMap<String, Object>();
        System.out.println("de");
        try {
            //获取当前用户
            User user = HrmUserVarify.getUser(request, response);
            DubanyBBAction DubantzAction=new DubanyBBAction();
            apidatas.putAll(DubantzAction.getSingleTablelist(ParamUtil.request2Map(request),user));
            apidatas.put("api_status", true);
        } catch (Exception e) {
            e.printStackTrace();
            apidatas.put("api_status", false);
            apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
        }
        return JSONObject.toJSONString(apidatas);
    }
    //获取查询列表数据页面
    @GET
    @Path("/dwtablelist")
    @Produces({"text/plain"})
    public String getdwtablelist(@Context HttpServletRequest request, @Context HttpServletResponse response){
        Map<String, Object> apidatas = new HashMap<String, Object>();
        System.out.println("de");
        try {
            //获取当前用户
            User user = HrmUserVarify.getUser(request, response);
            DubanyBBAction DubantzAction=new DubanyBBAction();
            apidatas.putAll(DubantzAction.getSingleDwTablelist(ParamUtil.request2Map(request),user));
            apidatas.put("api_status", true);
        } catch (Exception e) {
            e.printStackTrace();
            apidatas.put("api_status", false);
            apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
        }
        return JSONObject.toJSONString(apidatas);
    }
    //获取查询列表数据页面
    @GET
    @Path("/lxtablelist")
    @Produces({"text/plain"})
    public String getLxtablelist(@Context HttpServletRequest request, @Context HttpServletResponse response){
        Map<String, Object> apidatas = new HashMap<String, Object>();
        System.out.println("de");
        try {
            //获取当前用户
            User user = HrmUserVarify.getUser(request, response);
            DubanyBBAction DubantzAction=new DubanyBBAction();
            apidatas.putAll(DubantzAction.getSingleLxTablelist(ParamUtil.request2Map(request),user));
            apidatas.put("api_status", true);
        } catch (Exception e) {
            e.printStackTrace();
            apidatas.put("api_status", false);
            apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
        }
        return JSONObject.toJSONString(apidatas);
    }
    //获取查询列表数据页面
    @GET
    @Path("/condition")
    @Produces({"text/plain"})
    public String getQscondition(@Context HttpServletRequest request, @Context HttpServletResponse response){
        Map<String, Object> apidatas = new HashMap<String, Object>();
        System.out.println("de");
        try {
            //获取当前用户
            User user = HrmUserVarify.getUser(request, response);
            DubanyBBAction DubantzAction=new DubanyBBAction();
            apidatas.putAll(DubantzAction.getCondition(ParamUtil.request2Map(request),user));
            apidatas.put("api_status", true);
        } catch (Exception e) {
            e.printStackTrace();
            apidatas.put("api_status", false);
            apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
        }
        return JSONObject.toJSONString(apidatas);
    }
    

    private String handleSlash(String str){
        return str.replaceAll("/","");
    }

}
